package com.noocodecommit.wicket.jquery.plugin.ui.spinner;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;

import com.noocodecommit.wicket.jquery.TemplatePage;
import com.noocodecommit.wicket.stuff.jquery.JQCore;
import com.noocodecommit.wicket.stuff.jquery.plugin.chili.JQChili;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.spinner.JQSpinner;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.spinner.OnSpinDownBehavior;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.spinner.OnSpinUpBehavior;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.tabs.JQTabs;

public class SpinnerPage extends TemplatePage
{

	private static final long serialVersionUID = 1L;
	private final JQTabs tabContainer;

	public SpinnerPage()
	{
		super();
		JQCore.init(this);
		this.setupChili();

		tabContainer = new JQTabs("tab-container");
		tabContainer.setOutputMarkupId(true);
		add(tabContainer);

		JQSpinner spinner0 = new JQSpinner("spinner0");
		tabContainer.add(spinner0);

		/**
		 * 
		 */

		JQSpinner spinner1 = new JQSpinner("spinner1");
		tabContainer.add(spinner1);

		final Label output1 = new Label("output1");
		output1.setOutputMarkupId(true);
		tabContainer.add(output1);

		spinner1.add(new OnSpinDownBehavior()
		{
			@Override
			public void onDown(AjaxRequestTarget target)
			{
				output1.setModel(new Model("Spinning down"));
				target.addComponent(output1);
			}
		});

		spinner1.add(new OnSpinUpBehavior()
		{
			@Override
			public void onUp(AjaxRequestTarget target)
			{
				output1.setModel(new Model("Spinning up"));
				target.addComponent(output1);
			}
		});

		JQChili chili1 = new JQChili("chili1");
		add(chili1);
		this.bindChiliCode(chili1, this.getClass(), "html");

		JQChili chili2 = new JQChili("chili2");
		add(chili2);
		this.bindChiliCode(chili2, this.getClass(), "java");

		JQCore.get().bindOnDocumentReadyFunction();
	}
}
